/*
 * Copyright 2009-2010 Belmont Software Services
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.belmont.backup;

public class Status {
    static Status sharedInstance = new Status();
    public long counter;
    public String currentFile;
    public int filesToTransfer;
    public int filesTransferred;
    public long amountToTransfer;
    public long amountTransferred;
    public String currentTask;
    public String currentOperation;

    public static Status getInstance() {
        return sharedInstance;
    }

    public Status() {
    }

    public synchronized void copy(Status s) {
        s.counter = counter;
        s.currentFile = currentFile;
        s.filesToTransfer = filesToTransfer;
        s.filesTransferred = filesTransferred;
        s.amountToTransfer = amountToTransfer;
        s.amountTransferred = amountTransferred;
        s.currentTask = currentTask;
        s.currentOperation = currentOperation;
    }

    public synchronized void reset() {
        counter = 0;
        currentFile = null;
        filesToTransfer = 0;
        filesTransferred = 0;
        amountToTransfer = 0;
        amountTransferred = 0;
        currentTask = null;
        currentOperation = null;
    }

    public synchronized long getCounter() {
        return counter;
    }

    public synchronized void setCurrentFile(String f) {
        currentFile = f;
        counter++;
    }

    public synchronized String getCurrentFile() {
        return currentFile;
    }

    public synchronized void setFilesToTransfer(int f) {
        filesToTransfer = f;
        counter++;
    }

    public synchronized int getFilesToTransfer() {
        return filesToTransfer;
    }
    
    public synchronized void setFilesTransferred(int s) {
        filesTransferred = s;
        counter++;
    }

    public synchronized void addFilesTransferred(int s) {
        filesTransferred += s;
        counter++;
    }

    public synchronized int getFilesTransferred() {
        return filesTransferred;
    }

    public synchronized void setAmountToTransfer(long a) {
        amountToTransfer = a;
        counter++;
    }

    public synchronized long getAmountToTransfer() {
        return amountToTransfer;
    }

    public synchronized void setAmountTransferred(long a) {
        amountTransferred = a;
        counter++;
    }

    public synchronized void addAmountTransferred(long a) {
        amountTransferred += a;
        counter++;
    }

    public long getAmountTransferred() {
        return amountTransferred;
    }

    public void setCurrentTask(String t) {
        currentTask = t;
        counter++;
    }

    public String getCurrentTask() {
        return currentTask;
    }

    public void setCurrentOperation(String t) {
        currentOperation = t;
        counter++;
    }

    public String getCurrentOperation() {
        return currentOperation;
    }
}